package com.XinYun.Library.modules.admin.upload;


import com.XinYun.Library.modules.admin.upload.service.UploadService;
import com.XinYun.Library.modules.commons.BasicJson;
import com.XinYun.Library.modules.commons.BasicServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/api/upload/*")
public class UploadServlet extends BasicServlet {
    UploadService us = new UploadService();

    /**
     * 检验是否为图片并上传
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    public void uploadImg(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置返回json
        BasicJson<Object> json = new BasicJson<>();
        us.uploadImg(req, resp,json);
        sendJson(json,resp);
    }

}            